package site.assad.domain;

import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2017/12/17 12:47
 * Description:
 */
public class User {

    private int userId;

    //验证信息硬编码
/*    @NotNull(message="用户名不可为空")
    @Pattern(regexp = "\\S{2,15}",message="用户名必须包含2-15个非空字符")
    private String userName;

    @NotNull(message="用户密码不可为空")
    @Pattern(regexp = "\\w{6,30}",message="密码必须包含6-30个有字符，下划线，数字组成的字符")
    private String password;

    @Email(message="邮箱格式错误")
    private String email;

    @Past(message="必须是一个过去的日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;*/

    //验证信息国际化软编码
    @NotNull(message="{register.userName.notNull}")
    @Pattern(regexp = "\\S{2,15}",message="{register.userName.pattern}")
    private String userName;

    @Pattern(regexp = "\\w{6,30}",message="{register.password.pattern}")
    private String password;

    @Email(message="{register.email}")
    private String email;

    @Past(message="{register.birthday.past}")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", birthday=" + birthday +
                '}';
    }
}
